package com.srxz.mobilepharmacy.service;

import com.srxz.mobilepharmacy.entity.Hospital;
import com.srxz.mobilepharmacy.entity.UserInfo;
import com.srxz.mobilepharmacy.mapper.mapstruct.UserInfoMapper;
import com.srxz.mobilepharmacy.repository.UserInfoRepository;
import com.srxz.mobilepharmacy.util.back.BackMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigInteger;
import java.util.List;

@Service
@Transactional
public class UserInfoService {
    @Autowired
    private UserInfoRepository userInfoRepository;
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Transactional(readOnly = true)
    public BackMessage findUserInfoByHosp(BigInteger aid){
        List<UserInfo> userInfos = userInfoRepository.findUserInfoByName(aid);
        return BackMessage.success().putData("userinfos", userInfoMapper.dto(userInfos));
    }
}
